
#ifndef __TCP_H
#define __TCP_H
#include "common.h"
#include "util.h"

struct tcp_stream * tcp_stream_search(uint32_t s_ip, uint32_t d_ip, uint16_t s_port, uint16_t d_port);
struct tcp_stream * tcp_stream_create(uint32_t s_ip, uint32_t d_ip, uint16_t s_port, uint16_t d_port);

int tcp_pkg_process(struct rte_mbuf * m_buf);

int tcp_handle_listen(struct tcp_stream * stream, struct rte_tcp_hdr * tcphdr, struct rte_ipv4_hdr * iphdr);
int tcp_handle_syn_rcvd(struct tcp_stream * stream, struct rte_tcp_hdr * tcphdr);
int tcp_enqueue_recv_buf(struct tcp_stream * stream, struct rte_tcp_hdr * tcphdr, int tcp_len);
int tcp_send_ack(struct tcp_stream * stream, struct rte_tcp_hdr * tcphdr);
int tcp_handle_established(struct tcp_stream * stream, struct rte_tcp_hdr * tcphdr, int tcp_len);
int tcp_handle_close_wait(struct tcp_stream * stream, struct rte_tcp_hdr * tcphdr);
int tcp_handle_last_ack(struct tcp_stream * stream, struct rte_tcp_hdr * tcphdr);
int tcp_process(struct rte_mbuf * m_buf);
int tcp_out(struct rte_mempool * pool);
int tcp_server_entry(__attribute__((unused)) void * arg);

#endif